package beanstao.util.socket.protocol;

import java.util.concurrent.ConcurrentLinkedQueue;

import org.dom4j.Element;

import beanstao.util.log.LogHelper;

/**
 * 数据到达处理队列后的解析器(与取号主程序连接已断开)
 */
public abstract class AbstractMessageProcess implements IMessageProcess
{
	protected AbstractMessageProcess()
	{
		_SrcElement = new ConcurrentLinkedQueue<Element>();
	}

	@Override
	public void setMessage(Object msg)
	{
		if ((msg == null) || !(msg instanceof IProtocolMessage))
			return;
		IProtocolMessage srcMsg = ((IProtocolMessage) msg);
		_SrcElement.add(srcMsg.getMsgData());
		_SessionString = srcMsg.getSession();
		_CommandString = srcMsg.getCommand();
	}

	protected String _CommandString;

	protected String _SessionString;

	protected ConcurrentLinkedQueue<Element> _SrcElement;

	// = 日志接口(ILog)的实现 ============

	@Override
	public void logDebug(Object message)
	{
		LogHelper.logDebug(this, message);
	}

	@Override
	public void logDebug(Object message, Throwable t)
	{
		LogHelper.logDebug(this, message, t);
	}

	@Override
	public void logError(Object message)
	{
		LogHelper.logError(this, message);
	}

	@Override
	public void logError(Object message, Throwable t)
	{
		LogHelper.logError(this, message, t);
	}

	@Override
	public void logInfo(Object message)
	{
		LogHelper.logInfo(this, message);
	}

	@Override
	public void logInfo(Object message, Throwable t)
	{
		LogHelper.logInfo(this, message, t);
	}

	@Override
	public void logWarn(Object message)
	{
		LogHelper.logWarn(this, message);
	}

	@Override
	public void logWarn(Object message, Throwable t)
	{
		LogHelper.logWarn(this, message, t);
	}

}
